package com.arpa.wms.domain.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.IEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * 拣货单状态
 * @program: wms
 * @description:
 * @author: xuyang
 * @create: 2020-08-18 10:21
 */
public enum PickingStatusEnum implements IEnum<String> {
    /**
     * 待拣货
     */
    NOT_PICK("0", "待拣货"),
    /**
     * 拣货中
     */
    PICKING("1", "拣货中"),
    /**
     * 拣货完成
     */
    FINISH_PICK("2", "拣货完成");

    /**
     * 值
     */
    private final String value;

    /**
     * 描述
     */
    private final String desc;

    PickingStatusEnum(final String value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static PickingStatusEnum getByValue(String value) {
        for (PickingStatusEnum item : values()) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return null;
    }

    private static final Map<String,PickingStatusEnum> STATUS_MAP = new HashMap();

    static {
        PickingStatusEnum[] values = values();
        int length = values.length;
        for(int i = 0; i < length; i++){
            PickingStatusEnum value1 = values[i];
            STATUS_MAP.put(value1.getValue(),value1);
        }
    }

    public static String translate(String value) {
        PickingStatusEnum item = STATUS_MAP.get(value);
        if (item != null) {
            return item.getDesc();
        }
        return StrUtil.EMPTY;
    }

    @Override
    public String getValue() {
        return this.value;
    }

    @Override
    public String toString(){
        return this.desc;
    }

    public String getDesc() {
        return this.desc;
    }
}
